/**
 * Copyright:  Copyright (c) 2013
 *
 * @FileName		: CombinedPaperTotalAction.java
 * @PageName		: 
 * @Date			: 오후 2:33:09
 * @LastModifier	: 최경민
 * @LastModifyDate	: 
 * @LastModifier	: 
 * Change history	:
 */
package com.pulp.production.action;

import java.util.List;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.apache.struts2.ServletActionContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.pulp.production.service.ProductionInfoService;
import com.se.model.CommonSessionUser;

/**
 * @author 최경민
 *
 */
public class CombinedPaperTotalAction extends ActionSupport {
	private static final long serialVersionUID = 3978766981458065034L;
	private String REQUEST_RESULT = "ok";
	static Logger logger = Logger.getLogger(CombinedPaperTotalAction.class);

	private String errorCode = "";
	
	private List combinedPaperTotalYearList = null;
	private List combinedPaperTotalMonthList= null;
	private List combinedPaperTotalDateList = null;
	/**
	 * 
	 */
	public CombinedPaperTotalAction() {
		super();
		// TODO Auto-generated constructor stub
	}
	/**
	 * @return the rEQUEST_RESULT
	 */
	public String getREQUEST_RESULT() {
		return REQUEST_RESULT;
	}
	/**
	 * @param rEQUEST_RESULT the rEQUEST_RESULT to set
	 */
	public void setREQUEST_RESULT(String rEQUEST_RESULT) {
		REQUEST_RESULT = rEQUEST_RESULT;
	}
	/**
	 * @return the logger
	 */
	public static Logger getLogger() {
		return logger;
	}
	/**
	 * @param logger the logger to set
	 */
	public static void setLogger(Logger logger) {
		CombinedPaperTotalAction.logger = logger;
	}
	/**
	 * @return the errorCode
	 */
	public String getErrorCode() {
		return errorCode;
	}
	/**
	 * @param errorCode the errorCode to set
	 */
	public void setErrorCode(String errorCode) {
		this.errorCode = errorCode;
	}
	/**
	 * @return the combinedPaperTotalYear
	 */
	public List getCombinedPaperTotalYear() {
		return combinedPaperTotalYearList;
	}
	/**
	 * @param combinedPaperTotalYear the combinedPaperTotalYear to set
	 */
	public void setCombinedPaperTotalYear(List combinedPaperTotalYear) {
		this.combinedPaperTotalYearList = combinedPaperTotalYear;
	}
	/**
	 * @return the combinedPaperTotalMonth
	 */
	public List getCombinedPaperTotalMonth() {
		return combinedPaperTotalMonthList;
	}
	/**
	 * @param combinedPaperTotalMonth the combinedPaperTotalMonth to set
	 */
	public void setCombinedPaperTotalMonth(List combinedPaperTotalMonth) {
		this.combinedPaperTotalMonthList = combinedPaperTotalMonth;
	}
	/**
	 * @return the combinedPaperTotalDate
	 */
	public List getCombinedPaperTotalDate() {
		return combinedPaperTotalDateList;
	}
	/**
	 * @param combinedPaperTotalDate the combinedPaperTotalDate to set
	 */
	public void setCombinedPaperTotalDate(List combinedPaperTotalDate) {
		this.combinedPaperTotalDateList = combinedPaperTotalDate;
	}
	

	public String execute() throws Exception {
		System.out.println("CombinedPaperTotalAction==================");
		try {

			HttpServletRequest request = (HttpServletRequest) ServletActionContext.getRequest();
			ActionContext context = ActionContext.getContext();
			CommonSessionUser user = (CommonSessionUser) request.getSession().getAttribute(CommonSessionUser.ATTRIBUTE_NAME);
			ServletContext servletContext = ServletActionContext.getServletContext();
			WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(servletContext);
			ProductionInfoService productionInfoService = (ProductionInfoService) wac.getBean("productionInfoService");

			combinedPaperTotalYearList = productionInfoService.getCombinedPaperTotalYear();
			combinedPaperTotalMonthList = productionInfoService.getCombinedPaperTotalMonth();
			combinedPaperTotalDateList = productionInfoService.getCombinedPaperTotalDate();

			request.setAttribute("combinedPaperTotalYearList", combinedPaperTotalYearList);
			request.setAttribute("combinedPaperTotalMonthList", combinedPaperTotalMonthList);
			request.setAttribute("combinedPaperTotalDateList", combinedPaperTotalDateList);
		} catch (Exception ex) {
			REQUEST_RESULT = "FAILED";
			ex.printStackTrace();
		}
		return REQUEST_RESULT;
	}
	
}
